package com.yy.wga.income.service.controller;


import com.yy.wga.common.core.dto.Result;
import com.yy.wga.common.web.intereceptor.RequestHolder;
import com.yy.wga.income.feign.api.IncomeOrderGoodsFeign;
import com.yy.wga.income.feign.request.IncomeOrderListRequest;
import com.yy.wga.income.feign.response.IncomeOrderListResponse;
import com.yy.wga.income.service.service.IncomeOrderGoodsService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 订单收益
 *
 * @author guochao
 * @since 2024-11-12 00:27:45
 */
@RestController
@RequestMapping("/api/income/order")
public class IncomeOrderGoodsController implements IncomeOrderGoodsFeign {
    /**
     * 服务对象
     */
    @Resource
    private IncomeOrderGoodsService incomeOrderGoodsService;

    /**
     * 获取收益列表
     * @return
     */
    @PostMapping("list")
    public Result<List<IncomeOrderListResponse>> list(@RequestBody @Valid IncomeOrderListRequest request) {
        List<IncomeOrderListResponse> responseList = incomeOrderGoodsService.pageIncome(request);
        return Result.success(responseList);
    }

    @Override
    public Result<Boolean> orderSettle(String orderNo) {
        incomeOrderGoodsService.orderSettle(RequestHolder.getAppKey(), orderNo);
        return Result.success(Boolean.TRUE);
    }
}
